﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TaskBack.aspx.cs" Inherits="H2.NET.Web.Workflow.Workflow.TaskBack" %>

<script type="text/javascript">

    function DoTaskBack() {
        var selected = [];
        var $checkboxLi = $(":checkbox[name='ids']", $.pdialog.getCurrent());
        $checkboxLi.each(function () {
            if ($(this).attr("checked") == "checked") {
                selected.push($(this).attr("value"));
            }
        });

        if (selected.length == 0) {
            alertMsg.warn("至少选择一条数据");
            return false;
        }

        alertMsg.confirm("确定要收回所选的任务吗？", {
            okCall: function () {
                $.ajax({
                    type: "POST",
                    url: "Workflow/TaskBack.aspx?action=back_selected",
                    data: { ids: selected.join(",") },
                    cache: false,
                    dataType: "json",
                    success: function (result) {
                        if (result) {
                            alertMsg.correct("任务收回成功！");
                            $.pdialog.reload("Workflow/TaskBack.aspx");
                            navTab.reloadFlag("ToDoList"); //刷新待办事项
                        } else {
                            alertMsg.error("任务收回失败！");
                        }
                    },
                    error: function (response) {
                        alertMsg.error(response);
                    }
                });
            }
        });

        return false;
    }

    function DoFutureTaskBack() {
        alertMsg.confirm("确定要收回将来所有的任务吗？", {
            okCall: function () {
                $.ajax({
                    type: "POST",
                    url: "Workflow/TaskBack.aspx?action=future_back",
                    data: {},
                    cache: false,
                    dataType: "json",
                    success: function (result) {
                        if (result) {
                            alertMsg.correct("任务收回成功！");
                            $.pdialog.reload("Workflow/TaskBack.aspx");
                            navTab.reloadFlag("ToDoList"); //刷新待办事项
                        } else {
                            alertMsg.error("任务收回失败！");
                        }
                    },
                    error: function (response) {
                        alertMsg.error(response);
                    }
                });
            }
        });

        return false;
    }


</script>
<div class="pageContent">
    <form id="Form1" runat="server">
    <div class="pageFormContent"style="padding: 0px;">
        <table class="table" width="1200"  layouth="60" >
            <thead>
                <tr>
                    <th width="22">
                        <input type="checkbox" group="ids" class="checkboxCtrl">
                    </th>
                    <th width="60" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_monitor")%>
                    </th>
                    <th width="60" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_status")%>
                    </th>
                    <th width="200">
                        <%=clsCmm.getTextValue("frm_inbox_gv_process_name")%>
                    </th>
                    <th width="200">
                        <%=clsCmm.getTextValue("frm_inbox_gv_summary")%>
                    </th>
                    <th width="140" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_step_name")%>
                    </th>
                    <th width="140" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_start_time")%>
                    </th>
                    <th width="140" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_applicator")%>
                    </th>
                    <th width="100" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_owner")%>
                    </th>
                    <th width="100" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_incident_no")%>
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:repeater id="gvInbox" runat="server">
                <ItemTemplate>
                    <tr>
                        <td><input name="ids" value="<%# Eval("taskid") %>" processname="<%# Eval("processname3")%>" type="checkbox"></td>
                        <td><a href="javascript:;" onclick="return openDialog('<%# Eval("processname3")%>', 'workflow/monitor.aspx?TaskID=<%# Eval("taskid") %>', 1000, 600)" target="_blank"><img alt="<%=clsCmm.getTextValue("frm_inbox_img_alt")%>" border="0" src="../Resource/Images/<%# Eval("img_monitor") %>" width="16" height="16"></a></td>
                        <td><img alt="" border="0" src="../Resource/Images/<%# Eval("img_status") %>" width="16" height="16"></td>
                        <td><a href="javascript:;" onclick="<%#Eval("openform")%>" target="_blank"><%# Eval("processname3")%></a></td>
                        <td><a href="javascript:winOpenForm('<%# Eval("openform") %>?TaskID=<%# Eval("taskid") %>','tr_row_<%# Eval("taskid") %>')" target="_blank"><%# Eval("summary")%></a></td>
                        <td><%# Eval("steplabel")%></td>
                        <td><%# Eval("starttime","{0:yyyy-MM-dd HH:mm}")%></td>
                        <td><%# Eval("initiator_name")%></td>
                        <td><%# Eval("taskuser_name")%></td>
                        <td><%#Eval("incident")%></td>
                    </tr> 
                </ItemTemplate>
                
            </asp:repeater>
            </tbody>
        </table>
    </div>
    <div class="formBar">
        <ul>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="button" onclick="return DoTaskBack();">
                            收回选中的任务</button></div>
                </div>
            </li>
            <% if (is_future_task_has_assigned()) { %>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="button" onclick="return DoFutureTaskBack();">
                            收回将来所有任务</button></div>
                </div>
            </li>
            <% } %>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            关闭窗口</button></div>
                </div>
            </li>
        </ul>
    </div>
    </form>
</div>
